package com.jt.demo2.controller;

import com.jt.demo2.pojo.User;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/user3")
public class UserController2 {
    @RequestMapping("/findUser3")
    public String findUser3(HttpServletRequest request, HttpServletResponse response){
        String id = request.getParameter("id");
        int intId = Integer.parseInt(id);
        String name = request.getParameter("name");

        return intId+":"+name;
    }
    @RequestMapping("/findUser4")
    public String findUser4(Integer id,String name){

        return id+";"+name;
    }
    @RequestMapping("/getUser")
    public User getUser(User user){

        return user;
    }
    @RequestMapping("/resrFul")
    public User restFul(@PathVariable Integer id,@PathVariable String name){
            User user=new User();
            user.setId(id);
            user.setName(name);
        return user;
    }
    @RequestMapping("/restFul2")
    public User restFul2(User user){

        return user;
    }
    @RequestMapping("saveHobby")
    public String[] saveHobby(String[] hobby){
        return hobby;
    }
}
